<!--
  模块：一键求助 - 求助一览 - 新增
-->
<template>
  <div class="help-overview-add">
    <!-- 一键求助 - 求助一览 - 新增求助 -->
<<<<<<< HEAD
    <AppMainHeader>
      <el-row type="flex" justify="end" :gutter="20">
        <el-col :span="20"></el-col>
        <el-col :span="2" class="align-right">
          <el-button type="primary" @click="handleSave">保存</el-button>
        </el-col>
        <el-col :span="2" class="align-left">
          <el-button type="primary" @click="handleCommit">提交</el-button>
        </el-col>
      </el-row>
    </AppMainHeader>
    <AppMainContent>
      <el-card class="innerbox" style="height: 560px; overflow-y: scroll">
        <el-form
          ref="form"
          :model="helpForm"
          label-width="80px"
          label-position="top"
          size="small"
          :inline="true"
          :rules="ruleForm"
          :hide-required-asterisk="true"
        >
          <CardFormTitle title="企业信息" />
          <CardFormContent>
            <el-form-item
              label="企业名称"
              style="width: 46%"
              prop="companyName"
            >
              <el-input v-model="helpForm.companyName" disabled></el-input>
            </el-form-item>
            <br />
            <el-form-item
              label="社会信用代码"
              style="width: 22%; margin-right: 27px"
              prop="creditCode"
            >
              <el-input v-model="helpForm.creditCode" disabled></el-input>
            </el-form-item>
            <el-form-item
              label="企业分类"
              style="width: 22%"
              prop="companyType"
            >
              <el-select
                v-model="helpForm.companyType"
                placeholder="请选择"
                style="width: 100%"
                class="helpType"
                clearable
              >
                <el-option
                  v-for="item in companyTypeOptions"
                  :key="item.value"
                  :label="item.desc"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <br />
          </CardFormContent>
          <CardFormTitle title="问题诉求" />
          <CardFormContent>
            <el-form-item
              label="求助类型"
              style="width: 22%; margin-right: 27px"
              prop="helpType"
            >
              <el-select
                v-model="helpForm.helpType"
                placeholder="请选择"
                style="width: 100%"
                class="helpType"
                clearable
              >
                <el-option
                  v-for="item in helpTypeOptions"
                  :key="item.value"
                  :label="item.desc"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="求助时间" style="width: 22%" prop="helpTime">
              <el-date-picker
                v-model="helpForm.helpTime"
                type="datetime"
                placeholder="选择日期时间"
                style="width: 100%"
                disabled
                format="yyyy-MM-dd HH:mm"
                value-format="yyyy-MM-dd HH:mm"
              ></el-date-picker>
            </el-form-item>
            <br />
            <el-form-item
              label="问题和诉求描述"
              style="width: 46%"
              prop="queDes"
            >
              <el-input
                type="textarea"
                placeholder="请输入内容"
                v-model="helpForm.queDes"
                maxlength="30"
                show-word-limit
                rows="6"
                resize="none"
                class="queDes"
              ></el-input>
            </el-form-item>
          </CardFormContent>
        </el-form>
      </el-card>
      <Copyright />
    </AppMainContent>
=======
   <el-form label-position="top" :model="formParams" :rules="rules" ref="formParams" >

     <!-- 头部 -->
      <el-form-item class="header">
          <el-button type="primary" @click="saveForm('formParams')">保存</el-button>
          <el-button type="primary" @click="submitForm('formParams')">提交</el-button>
      </el-form-item>

     <!-- 内容 -->
      <div class="content">
         <el-row :gutter="20">
        <el-col :span="12" class="contents">
              <div class="left">

                  <CardFormTitle title="企业信息"></CardFormTitle>

                  <CardFormContent>

                    <el-form-item  label="企业名称">
                        <el-input
                            v-model="formParams.companyName"
                            clearable
                            disabled
                          />
                    </el-form-item>

                    <el-col :span="12">
                      <el-form-item  label="社会信用代码">
                          <el-input
                              v-model="formParams.creditCode"
                              clearable
                              disabled
                          />
                      </el-form-item>
                    </el-col>

                    <el-col :span="12">
                      <el-form-item  label="企业分类">
                          <el-input
                              v-model="formParams.companyType.desc"
                              clearable
                              disabled
                          />
                      </el-form-item>
                    </el-col>
                  </CardFormContent>

                  <div>
                  <CardFormTitle title="问题述求"></CardFormTitle>
                  </div>

                  <CardFormContent>



                  <el-col :span="12">
                    <el-form-item  label="求助类型"  prop="helpType">
                      <el-select
                            v-model="formParams.helpType"
                            placeholder="求助类型"
                            clearable

                            >
                          <el-option
                                v-for="dict in pulldown.helpType"
                                :key="dict.value"
                                :label="dict.desc"
                                :value="dict.value"
                            />
                      </el-select>
                    </el-form-item>
                  </el-col>

                  <el-col :span="12">
                    <el-form-item  label="求助时间">
                        <el-date-picker
                            v-model="Time"
                            type="datetime"
                            clearable
                            disabled
                          />
                    </el-form-item>
                  </el-col>

                  <el-col :span="24">
                    <el-form-item  label="问题和述求描述" prop="queDes">
                        <el-input
                            v-model="formParams.queDes"
                            clearable
                            type="textarea"
                            maxlength="1000"
                            show-word-limit

                          />
                    </el-form-item>
                  </el-col>
                  </CardFormContent>


              </div>

            </el-col>
         </el-row>
          </div>

      </el-form>
>>>>>>> f75ca00bc8d57da1690255e0caf41a610804c028
  </div>
</template>

<script>
<<<<<<< HEAD
import { getHelpTypeOptions, addSaveHelp } from '@/api/help/helpAdd'
export default {
  name: 'HelpOverviewAdd',
  data() {
    return {
      helpForm: {},
      helpTypeOptions: [],
      companyTypeOptions: [],
      ruleForm: {
        helpType: [
          {
            required: true,
            message: '请选择求助类型',
            trigger: 'change',
          },
        ],
        queDes: [
          {
            required: true,
            message: '请填写问题和诉求描述',
            trigger: 'blur',
          },
        ],
      },
    }
  },
  methods: {
    handleSave() {
      this.$refs['form'].validate((flag) => {
        console.log(this.helpForm)
        if (flag) {
          addSaveHelp(this.helpForm).then(() => {
            console.log(response)
          })
        } else {
          alert('请检查内容!')
        }
      })
    },
    handleCommit() {},
  },
  mounted() {
    getHelpTypeOptions().then((response) => {
      console.log(response)
      this.companyTypeOptions = response.data.companyType
      this.helpTypeOptions = response.data.helpType
      // console.log(this.$store.getters.userInfo)
      this.helpForm.companyName = this.$store.getters.userInfo.companyName
      this.helpForm.creditCode = ''
      this.helpForm.helpTime = new Date()
    })
  },
=======
  // 样式
  import CardFormContent from "@/components/card-form-content"
  // 样式
  import CardFormTitle from "@/components/card-form-title"
   // 详情数据请求
  import { detailsdata } from '@/api/help/input'
  import { formatDate } from '@/api/help/reply'
  import { pulldown,addSaveHelp,addSubmitHelp } from '@/api/help/overview'
export default {
  name: 'HelpOverviewAdd',

   created(){
      alert(this.$store.getters.userInfo)
  },

  mounted:function(){
    let _this = this;
    _this.$nextTick(function(){
      setInterval(_this.getdatatime,100000)
    })
  },

  created() {
      // 获取头部表单下拉数据
      this.getPulldown()
    },


  data(){
    return {
        // 时间
        Time: new Date(),
        // 详情信息
        formParams:{
          companyName:this.$store.getters.userInfo.companyName,
          creditCode:320682199812127766,
          companyType:{
              desc:"规上企业",
              value:1
          },
          helpType:undefined,
          helpTime:undefined,

          queDes:undefined,
          createUserId:this.$store.getters.userInfo.id,
          createUserName:this.$store.getters.userInfo.userName,
          createTime:undefined



        },

        // 下拉数据
        pulldown:{},

        // 数据校验
        rules:{
            helpType:[
              { required: true, message: '请选择类型', trigger: 'change' },
            ],
            queDes:[
               { required: true, message: '请输入问题和述求描述', trigger: 'blur' },
               { min: 1, max: 1000, message: '长度在 1 到 1000 个字符', trigger: 'blur' }
            ]

      }
    }
  },

  methods:{
      // 显示时间方法
      getdatatime(){
          this.Time = new Date();
      },
      // 获取头部表单下拉数据
      getPulldown(){
            pulldown().then((responseOne)=>{
            this.pulldown = responseOne.data;
        })
      },

      // 数据保存
      saveForm(formParams) {
        this.$refs[formParams].validate((valid) => {
          if (valid) {
            let type = 1
            this.formParams.helpTime = formatDate(this.Time,'yyyy-MM-dd hh:mm:ss')
            this.formParams.createTime = this.formParams.helpTime
            this.formParams.companyType = type
            addSaveHelp(this.formParams).then((Response)=>{
                this.$router.push({
                 name:"HelpOverview"
                })
            window.location.reload()
          })


          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },


      // 数据提交
      submitForm(formParams){
        this.$refs[formParams].validate((valid) => {
          if (valid) {
            let type = 1
            this.formParams.helpTime = formatDate(this.Time,'yyyy-MM-dd hh:mm:ss')
            this.formParams.createTime = this.formParams.helpTime
            this.formParams.companyType = type
            addSubmitHelp(this.formParams).then((Response)=>{
                this.$router.push({
                 name:"HelpOverview"
                })
            window.location.reload()
          })


          } else {
            console.log('error submit!!');
            return false;
          }
        });
      }

  }
>>>>>>> f75ca00bc8d57da1690255e0caf41a610804c028
}
</script>

<style lang="scss" scoped>
<<<<<<< HEAD
.helpType::after {
  content: '*';
  color: red;
  position: absolute;
  right: -12px;
  top: -3px;
}
.queDes::after {
  content: '*';
  color: red;
  position: absolute;
  right: -12px;
  top: -3px;
}
.innerbox::-webkit-scrollbar {
  width: 4px;
}
.innerbox::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.2);
}
.innerbox::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}
=======
  .header{
    width: 100%;
    padding: 10px;
    padding-right: 20px;
    background-color: white;
    text-align: right;
  }


  .content {
    width: 100%;
    height: 700px;
    padding-top: 24px;
    padding-left: 48px;
    padding-right: 48px;

    & .contents{
    border:20px solid rgb(226, 232, 240);
    height: 623px;
    background-color: rgb(255, 255, 255);
    text-align: left;
  }

  }


  .left{
    text-align: left;
  }

  .card-form-title{
    margin-top: 40px;
    padding-left: 10px;

  }

  .card-form-content{
      height:165px;
      width: 60%;
      margin-left: 20px;
  }

  .right-content{
    height: 75px;
  }

  .righttwo{
    height: 240px;
  }






>>>>>>> f75ca00bc8d57da1690255e0caf41a610804c028
</style>

